@use '../core' as *;

// Ignore padding & remove border if within tabbed container
:global(.tabs-outer) .expandableSnippet pre:global(.code) {
    margin: -$spacing-size-4;
    border: none;
}

.expandableSnippet {
    position: sticky;
    top: var(--total-header-height);
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100vh - var(--total-header-height));
    z-index: 3;

    @media screen and (min-width: $breakpoint-options-medium) {
        overflow-y: auto;
        z-index: unset;
    }

    > header {
        position: sticky;
        top: 0;
        left: 0;
        z-index: 3;
        width: 100%;
        padding: $spacing-size-4 var(--horizontal-margin);
        background-color: var(--color-bg-primary);
        border-bottom: 1px solid var(--color-util-gray-200);

        @media screen and (min-width: $breakpoint-options-medium) {
            padding: $spacing-size-4 $spacing-size-4 $spacing-size-4 var(--layout-horizontal-margins);
        }

        @media screen and (min-width: $breakpoint-options-extra-large) {
            padding: $spacing-size-4;
        }

        h3 {
            margin-bottom: 0;
        }

        p {
            line-height: var(--text-lh-tight);
        }
    }

    > pre {
        flex: 1 0 auto;
        margin-bottom: 0;
        border: none;
        border-radius: 0;
        overflow-y: hidden;

        > code {
            --code-line-height: 1.75;

            min-height: 100%;
            padding: 8px 0 105px;
            line-height: var(--code-line-height);
            background-size: 1px calc(1em * var(--code-line-height) * 2);
        }
    }

    input[type='search'] {
        width: 100%;

        &.searchInput {
            padding-left: 2em;
        }
    }
}

.navContainer {
    --nav-options-indent: 24px;

    display: none;
    user-select: none;

    @media screen and (min-width: $breakpoint-options-medium) {
        display: block;
    }
}

.navContainer > code {
    #{$selector-darkmode} & {
        background: var(--color-bg-tertiary);
    }
}

.navGroup {
    position: relative;

    &.groupWhiskers::before,
    &.groupWhiskers::after {
        content: '';
        position: absolute;
        left: calc(4px + var(--nav-options-indent) * (var(--options-nav-depth, 0) - 1));
        background-color: var(--color-util-gray-300);
        pointer-events: none;

        #{$selector-darkmode} & {
            background-color: var(--color-util-gray-400);
        }
    }

    &.groupWhiskers::before {
        top: -4px;
        bottom: -14px;
        width: 1px;
        transform: translateX(5px);
    }

    &.groupWhiskers::after {
        bottom: -14px;
        height: 1px;
        width: 8px;
        transform: translateX(5px);
    }
}

.navItem {
    padding: 0 16px 0 calc(var(--layout-horizontal-margins) + var(--nav-options-indent) * var(--options-nav-depth, 0));

    @media screen and (min-width: $breakpoint-options-extra-large) {
        padding: 0 16px 0 calc(#{$spacing-size-4} + var(--nav-options-indent) * var(--options-nav-depth, 0));
    }

    &:global(.highlight) {
        position: relative;

        &::before {
            content: '';
            position: absolute;
            inset: 0;
            background-color: var(--color-util-brand-400);
            #{$selector-darkmode} & {
                background-color: color-mix(in srgb, var(--color-util-brand-700), var(--color-bg-primary) 20%);
            }
            opacity: 0.15;
            pointer-events: none;
        }
    }
}

.propertyExpander {
    --icon-size: 1em;
    --color-icon: var(--color-fg-primary);

    position: absolute;
    top: 0;
    right: 100%;
    padding: 3px;
    box-sizing: content-box;
    transition: transform $transition-default-timing;

    &.active {
        transform: rotate(90deg);
    }
}

.propertyName {
    position: relative;
    color: var(--color-fg-primary);
    cursor: pointer;

    .punctuation {
        color: var(--punctuation-color);
    }

    .unionDiscriminator {
        color: var(--color-fg-code);
    }
}

.propertyWhisker {
    position: relative;

    &::before {
        content: '';
        position: absolute;
        top: 8.5px;
        right: calc(100% + 10px);
        width: var(--nav-options-indent);
        height: 1px;
        background-color: var(--color-util-gray-300);

        #{$selector-darkmode} & {
            background-color: var(--color-util-gray-400);
        }
    }
}

.propertyExpandable {
    &.propertyWhisker::before {
        right: calc(100% + 22px);
        width: calc(var(--nav-options-indent) - 12px);
    }
}

.searchOuter {
    position: relative;
    display: flex;
    align-items: center;

    input::-webkit-search-cancel-button {
        display: none;
    }
}

.searchIcon {
    --icon-size: 1.25em;
    --color-icon: var(--color-fg-secondary);

    position: absolute;
    left: 0.625em;
}

.searchDropdown {
    position: absolute;
    inset: 100% 0 auto;
    max-height: 168px;
    border-bottom-right-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
    background-color: var(--color-bg-primary);
    border: 1px solid var(--color-input-border);
    border-top: none;
    overflow: auto;
    z-index: 3;

    #{$selector-darkmode} & {
        inset: 100% 0 auto;
    }
}

.searchOptions {
    display: flex;
    flex-direction: column;
    min-width: fit-content;
    white-space: nowrap;
}

.searchOption {
    padding: $spacing-size-2 $spacing-size-4;
    cursor: pointer;

    strong {
        color: var(--color-util-brand-700);

        #{$selector-darkmode} & {
            color: var(--color-fg-primary);
        }
    }

    &.selected {
        background-color: var(--color-util-brand-100);

        #{$selector-darkmode} & {
            background-color: rgba(255, 255, 255, 0.1);
        }
    }
}
